package com.inspsys.inspection.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.inspsys.common.annotation.Log;
import com.inspsys.common.core.controller.BaseController;
import com.inspsys.common.core.domain.AjaxResult;
import com.inspsys.common.enums.BusinessType;
import com.inspsys.inspection.domain.InspectionImage;
import com.inspsys.inspection.service.IInspectionImageService;
import com.inspsys.common.utils.poi.ExcelUtil;
import com.inspsys.common.core.page.TableDataInfo;

/**
 * 巡检图像Controller
 *
 * @author inspsys
 * @date 2025-01-08
 */
@RestController
@RequestMapping("/inspection/image")
public class InspectionImageController extends BaseController
{
    @Autowired
    private IInspectionImageService inspectionImageService;

    /**
     * 查询巡检图像列表
     */
    @PreAuthorize("@ss.hasPermi('inspection:image:list')")
    @GetMapping("/list")
    public TableDataInfo list(InspectionImage inspectionImage)
    {
        startPage();
        List<InspectionImage> list = inspectionImageService.selectInspectionImageList(inspectionImage);
        return getDataTable(list);
    }

    /**
     * 导出巡检图像列表
     */
    @PreAuthorize("@ss.hasPermi('inspection:image:export')")
    @Log(title = "巡检图像", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InspectionImage inspectionImage)
    {
        List<InspectionImage> list = inspectionImageService.selectInspectionImageList(inspectionImage);
        ExcelUtil<InspectionImage> util = new ExcelUtil<InspectionImage>(InspectionImage.class);
        util.exportExcel(response, list, "巡检图像数据");
    }

    /**
     * 获取巡检图像详细信息
     */
    @PreAuthorize("@ss.hasPermi('inspection:image:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(inspectionImageService.selectInspectionImageById(id));
    }

    /**
     * 新增巡检图像
     */
    @PreAuthorize("@ss.hasPermi('inspection:image:add')")
    @Log(title = "巡检图像", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InspectionImage inspectionImage)
    {
        return toAjax(inspectionImageService.insertInspectionImage(inspectionImage));
    }

    /**
     * 修改巡检图像
     */
    @PreAuthorize("@ss.hasPermi('inspection:image:edit')")
    @Log(title = "巡检图像", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InspectionImage inspectionImage)
    {
        return toAjax(inspectionImageService.updateInspectionImage(inspectionImage));
    }

    /**
     * 删除巡检图像
     */
    @PreAuthorize("@ss.hasPermi('inspection:image:remove')")
    @Log(title = "巡检图像", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(inspectionImageService.deleteInspectionImageByIds(ids));
    }
}
